<template>
  <div class="app-container">
      <!-- 采购计划审批  获取当前用户可以审批的数据-->
    <el-table v-loading="loading" :data="list" border>
      <el-table-column align="center" type="index" label="序号" width="55"/>
      <el-table-column align="center" label="计划单号" property="itemCode" width="150">
        <template slot-scope="scope" style="text-align: center">
            <!-- v-hasPermi="['purchaseGL:done:details']" -->
          <el-button size="mini" type="text" @click="details(scope.row)" >
            {{scope.row.itemCode}}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column align="center" label="标题" property="itemTitle" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column label="通知时间" align="center" property="todoTime" r width="180">
      </el-table-column>
      <el-table-column align="center" label="创建人" property="applyUserName"></el-table-column>
      <el-table-column align="center" label="备注" property="itemContent" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column label="操作" align="center" width="260" fixed="right">
        <template slot-scope="scope">
          <el-button size="mini" type="warning" icon="el-icon-date" @click="openHisChange(scope.row)">审批历史</el-button>
          <el-button size="mini" type="primary" icon="el-icon-picture-outline" @click="openImgChange(scope.row)">进度查看</el-button>
        </template>
      </el-table-column>
    </el-table>
        <pagination :total="total" :page.sync="selectForm.pageNum" :limit.sync="selectForm.pageSize" @pagination="getList"/>
    <history-dia v-if="isHisDia" :info="hisInfo" @change="closeHisChange"></history-dia>
    <image-dia v-if="isImgDia" :info="imgInfo" @change="closeImgChange"></image-dia>
    <procure-plan-des v-if="isprocureDes" @subSetChane="subSetChane" :pid="pid"></procure-plan-des>
  </div>
</template>

<script>
  import { taskDoneList,approve} from '@/api/repair/index'
  import historyDia from '../notDone/historyDia'
  import imageDia from '../notDone/imageDia'
  import procurePlanDes from '@/views/maintain/sqdXQ'
export default {
    components:{
        historyDia,
        imageDia,
        procurePlanDes
    },
    data(){
        return{
            selectForm:{
                pageNum:1,
                pageSize:10
            },
            loading:false,
            list:[],
            total:0,
            roles:this.$store.state.user.roles.join(','),
            isHisDia:false,
            hisInfo:null,
            isImgDia:false,
            imgInfo:null,

            isprocureDes:false,
            pid:null
        }
    },
    created(){
        this.getList()
    },
    methods:{
        getList(){
            this.loading = true
            taskDoneList(this.selectForm).then((res)=>{
                if(res.code==200){
                    this.list = res.rows
                    this.total=res.total
                    this.loading = false
                }
            })

        },
        approve(info){
            approve(info).then((res)=>{
                if(res.code==200){
                    this.$message.success(res.msg)
                    this.getList()
                }
            })
        },
        approval(row,falg){
            this.$confirm('是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
                }).then(() => {
                    this.approve({taskId:row.taskId,
                    agree:falg,moduleId:row.moduleId,instanceId:row.instanceId})
                }).catch(() => {
                    this.$message({
                    type: 'info',
                    message: '已取消'
                });
            });
        },
        details(row) {
            // this.$router.push({ path: '/purchaseGL/applicationXQ', query: { data: row.moduleId } })
            this.pid=row.moduleId
            this.isprocureDes=true
        },
        subSetChane(info){
            this.isprocureDes=false
            this.pid=null
        },
        openHisChange(row){
            this.hisInfo=row
            this.isHisDia=true

        },
        closeHisChange(info){
            if(info){

            }
            this.isHisDia=false
        },
        openImgChange(row){
            this.imgInfo=row
            this.isImgDia=true

        },
        closeImgChange(info){
            if(info){

            }
            this.isImgDia=false
        },
    }
}
</script>

<style>

</style>
